package com.zhoug.zmui3demo.ui;

import android.os.Bundle;
import android.text.Editable;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.Switch;
import android.widget.Toast;

import com.zhoug.common3.interfaces.TextChangedListener;
import com.zhoug.common3.utils.LogUtils;
import com.zhoug.zmui3.ZMUIPhoneEditText;
import com.zhoug.zmui3.input.ZMUIInputEditText;
import com.zhoug.zmui3.input.ZMUIInputTextView;
import com.zhoug.zmui3demo.R;

import androidx.annotation.Nullable;

/**
 * @Author: zhoug
 * @Date: 2024-07-08
 * @Description:
 */
public class ZMUIInputEditTextViewActivity extends ZMUIInputViewBaseActivity {
    private static final String TAG = ">>>ZMUIInputEditTextAc";
    private Switch switchEnable;
    private Switch switchError;
    private ZMUIPhoneEditText phoneEditText1;
    private ZMUIPhoneEditText phoneEditText2;
    private ZMUIInputEditText inputEditTextView11;
    private ZMUIInputEditText inputEditTextView12;
    private ZMUIInputEditText inputEditTextView13;
    private ZMUIInputEditText inputEditTextView14;
    private ZMUIInputEditText inputEditTextView15;
    private ZMUIInputEditText inputEditTextView21;
    private ZMUIInputEditText inputEditTextView23;
    private ZMUIInputEditText inputEditTextView24;
    private ZMUIInputEditText inputEditTextView25;
    private LinearLayout contentView;

    @Override
    protected void onCreated(@Nullable Bundle savedInstanceState) {
        setContentView(R.layout.activity_input_edit_text_view);
        findViews();
        inputEditTextView11.setOnRightIconClickListener((inputView, icon) -> {
            if(inputView instanceof ZMUIInputTextView inputTextView){
                String value = inputTextView.getValue();
                Toast.makeText(this, "#"+value+"#", Toast.LENGTH_SHORT).show();
            }
        });
        inputEditTextView12.setOnRightIconClickListener((inputView, icon) -> {
            if(inputView instanceof ZMUIInputTextView inputTextView){
                String value = inputTextView.getValue();
                Toast.makeText(this, "#"+value+"#", Toast.LENGTH_SHORT).show();
            }
        });

        phoneEditText1.addTextChangedListener(new TextChangedListener() {
            @Override
            public void afterTextChanged(Editable s) {
                LogUtils.d(TAG, "PhoneNumber1:"+phoneEditText1.getPhoneNumber());
            }
        });
        phoneEditText2.addTextChangedListener(new TextChangedListener() {
            @Override
            public void afterTextChanged(Editable s) {
                LogUtils.d(TAG, "PhoneNumber2:"+phoneEditText2.getPhoneNumber());
            }
        });

    }

    @Override
    protected ViewGroup getContentView() {
        return contentView;
    }

    @Override
    protected Switch getEnableSwitchView() {
        return switchEnable;
    }

    @Override
    protected Switch getErrorSwitchView() {
        return switchError;
    }

    private void findViews() {
        switchEnable = findViewById(R.id.switch_enable);
        switchError = findViewById(R.id.switch_error);
        phoneEditText1 = findViewById(R.id.phoneEditText1);
        phoneEditText2 = findViewById(R.id.phoneEditText2);
        inputEditTextView11 = findViewById(R.id.inputEditTextView11);
        inputEditTextView12 = findViewById(R.id.inputEditTextView12);
        inputEditTextView13 = findViewById(R.id.inputEditTextView13);
        inputEditTextView14 = findViewById(R.id.inputEditTextView14);
        inputEditTextView15 = findViewById(R.id.inputEditTextView15);
        inputEditTextView21 = findViewById(R.id.inputEditTextView21);
        inputEditTextView23 = findViewById(R.id.inputEditTextView23);
        inputEditTextView24 = findViewById(R.id.inputEditTextView24);
        inputEditTextView25 = findViewById(R.id.inputEditTextView25);
        contentView = findViewById(R.id.contentView);
    }
}
